<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use Hash;

class LoginController extends Controller
{
    public function getIndex()
    {
        return view('home/login/index');
    }
    public function postDologin(Request $request)
    {
        $s = DB::table('shop_user') -> where('email', $request -> input('username')) -> orWhere('tel', $request -> input('username')) -> first();
        $res = Hash::check($request -> input('password'), $s['userpwd']);
        if($res){
            if($s['status'] == 2){
                if($request -> input('code') == session('code')){
<<<<<<< HEAD
                    session(['nickname' => $s['nickname'], 'userpic' => $s['userpic'], 'login' => '1']);
                    return view('home/home/index');
=======
<<<<<<< HEAD
                    //session(['id' => $s['id'],'username' => $s['username'],'email'=> $s['email'],'tel' => $s['tel']]);
                    session(['nickname' => $s['nickname'], 'userpic' => $s['userpic'], 'login' => '1','id' => $s['id'],'email'=> $s['email'],'tel' => $s['tel']]);
                    return view('home/home/index');
=======
                    session(['nickname' => $s['nickname'], 'userpic' => $s['userpic'], 'login' => '1']);
                    return redirect('http://www.yishow.com/');
>>>>>>> 87693f2ddbb50b78dddd82d04d1015e9f44933de
>>>>>>> 31e42f2d3415b82d4888522298db4e7de5f9c8aa
                 }else{
                   return view('home/login/index', ['xinxi' => '验证码不正确']);
                 }
               
            }else{
               return view('home/login/index', ['xinxi' => '该用户未激活']);
            }
        }else{
            return view('home/login/index', ['xinxi' => '用户名或密码不正确']);
        }
    }
}
